
#region Using Statements

    using System;
    using System.Text;
    using System.Linq;
    using System.Diagnostics;
    using Microsoft.Xna.Framework;

#endregion

namespace HumanElement.Xna.Construct
{
    /// <summary>
    /// 
    /// </summary>
    static class Program
    {
        internal const int ERR_UNKNOWN = -1;

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main(string[] args)
        {

            #region Platform Specific Setup Code

#if(WIN32)

#elif(XBOX360)

#elif(ZUNE)

#else

#endif

            #endregion

            var games = args.Select(p => p.StartsWith("/g:"));

            // LogEvent(1000, "[ARG] (/game: | /g:) Loading Game from manifest:\t", null, null, args);

            foreach(var game in games)
            {
                var gameManifest = new GameManifest();

                using (var construct = new Construct())
                {
                    try
                    {
                        
                        construct.LoadGame(gameManifest);

                        var res = construct.TestConntect();
                    }
                    catch (Exception ex)
                    {
                        LogEvent(ERR_UNKNOWN, "Unknown Error", construct.LastGameTime, ex);
                    }
                    finally
                    {
                        // TODO: Add any tead down code here.
                    }
                }
            }
        }


        

        /// <summary>
        /// Logs the event.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="id">The id.</param>
        /// <param name="name">The name.</param>
        /// <param name="gameTime">The game time.</param>
        /// <param name="payload">The payload.</param>
        /// <param name="args">The args.</param>
        internal static void LogEvent<T>(int id, string name, GameTime gameTime, T payload, params string[] args)
        {
            Debug.WriteLine(String.Format(" --- [{0}|{1}] {2} \n", id, gameTime.TotalGameTime, name));
        
            var sb = new StringBuilder();
            
            sb.Append(payload.ToString());

            foreach(var a in args)
            {
                sb.AppendFormat("\t| {0}", a);
            }

            Debug.WriteLine(String.Format("{0}\n\n", sb));
        }
    }
}

